<script type="text/javascript">
$(function () {
	var url = '${contextPath}script/oa/documentInfo.js?time=' + sys_get_time();
	$.ajax({url:url, dataType:'script', cache:true,
		success: function(){
			<#if !((documentInfo.code)??)>
			addFilesUploadEvent_documentInfo();
			</#if>
		}
	});
	$('.dn').autocomplete(${(type)!'[]'}, {
		
		max: 12,    //列表里的条目数
		minChars: 0,    //自动完成激活之前填入的最小字符
		width: 220,     //提示的宽度，溢出隐藏
        scrollHeight: 300,   //提示的高度，溢出显示滚动条
        matchContains: true,    //包含匹配，就是data参数里的数据，是否只要包含文本框里的数据就显示
        autoFill: false,    //自动填充
        formatItem: function(row, i, max) {
      	  return i + '/' + max + ':"' + row.dn + '"';
        },
        formatMatch: function(row, i, max) {
      	  return row.dn + row.dc;
        },
        formatResult: function(row) {
      	  return row.dn;
		}
	}).result(function(event, row, formatted) {
		$('.dc').val(row.dc);
	});
	$('#editDocumentInfoForm').find("input:checkbox, input:radio").not('input.ibtn').uniform();
});	
</script>

<#import "/freemarker/modeltype.ftl" as mt>
<#import "/freemarker/modeltype_entity.ftl" as mte>

<div class="widget" style="float:left;">
	<div class="widget-header">
		<h3 class="title"><i class="fontello-icon-th-list-1"></i> 编辑文档/消息</h3>
	</div>  
	<div class="widget-content">
		<form id="editDocumentInfoForm">
		<#assign i = 0/>
		<#list list as d>
			<div class="rep">
				<input type="hidden" name="list[${i}].code" value="${(d.code)!''}" />
				<input type="hidden" value="${(d.pType)!''}" id="t"/>
				<table class="table table-bordered animate2 fadeInUp" style="width:100%; text-align:left;">
					<tr>
						<td class="table-left" style="width:100px;">名称</td>
						<td><input type="text" id="title" name="list[${i}].name" style="width:600px;" value="${(d.name)!''}" />
							<input type="hidden" name="list[${i}].uuid" value="${(d.uuid)!''}"/>
							<input type="hidden" name="list[${i}].ext" value="${(d.ext)!''}"/>
							<input type="hidden" name="list[${i}].size" value="${(d.size)!''}"/>
						</td>
						<td rowspan="4" style="text-align:center;">
							<a href="javascript:;" class="btn btn-xs btn-danger" style="margin-top:40px;" onclick="javascript: delete_documentInfo($(this));"><i class="icon-remove"></i>&nbsp;删&nbsp;&nbsp;除</a>
						</td>
					</tr>
	      		 	<tr>
		      		 	<td class="table-left">文档类别</td>
						<td><input id="dn" name="list[${i}].dn" value="${(d.dn)!''}" type="text" class="dn"/>
							<input id="dc" name="list[${i}].dc" value="${(d.dc)!''}" type="hidden" class="dc"/>
						</td>
	          		</tr>
					<tr>
						<td class="table-left">公开权限</td>
						<td><input id="all_${i}" <#if d.pType?? && d.pType == 1> checked="checked"</#if> type="radio" name="list[${i}].pType" value="1" onclick="javascript:$('#ptypeObjList_${i}').hide();">完全公开</input>
							<input<#if d.pType?? && d.pType == 2> checked="checked"</#if> type="radio" name="list[${i}].pType" value="2" onclick="javascript:$('#ptypeObjList_${i}').hide();">仅自己可见</input>
							<input<#if d.pType?? && d.pType == 3> checked="checked"</#if> type="radio" name="list[${i}].pType" value="3" onclick="javascript:selectOrgan_documentInfo(${i},$(this)); $('#ptypeObjList_${i}').show();">指定机构</input>
							<input<#if d.pType?? && d.pType == 4> checked="checked"</#if> type="radio" name="list[${i}].pType" value="4" onclick="javascript:selectRole_documentInfo(${i},$(this)); $('#ptypeObjList_${i}').show();">指定角色</input>
							<input<#if d.pType?? && d.pType == 5> checked="checked"</#if> type="radio" name="list[${i}].pType" value="5" onclick="javascript:selectUser_documentInfo(${i},$(this)); $('#ptypeObjList_${i}').show();">指定用户</input>
						</td>
					</tr>
					<tr>
						<td colspan="2" class="td-rep" style="display:none;"></td>
					</tr>
				</table>
				<div>
					<div id="ptypeObjList_${i}">
					<#if d.publicList??>
					<#list p as item> 
						<div class="filter-table rep" style="margin-left:5px; margin-bottom:0px;">
						<input class="pc" type="hidden" name="list[i].publicList[j].pc" value="${item[0]}">
						<button class="close" onclick="javascript:deleteSelectedItem($(this));" data-dismiss="alert" type="button">×</button>
						<a class="title" href="#">${item[1]}</a>
						</div>
					</#list>
					</#if>
					</div>
				</div>
			</div>
			<br/>
			<#assign i =  i + 1/>
			</#list>
			<tr height="40">
				<td colspan="2" style="text-align: center;"></td>
				<td><a href="javascript:;" class="btn btn-info" onclick="javascript: saveDocumentInfo_documentInfo(); return false;"><i class="icon-save"></i>&nbsp;确定上传</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="javascript:;" class="btn btn-primary" onclick="javascript: sys_load_handle('documentInfo');"><i class="fontello-icon-block"></i>&nbsp;取&nbsp;&nbsp;消</a>
				</td>
			</tr>
		</form>
	</div>
</div>

<div id="tempAnnexListDiv" style="display:none;">
	<div class="filter-table rep" style="margin:0px 5px -10px 0px;">
		<input class="name" type="hidden" />
		<input class="size" type="hidden" />
		<input class="uuid" type="hidden" />
		<input class="ext" type="hidden" />
		<button type="button" class="close" data-dismiss="alert" onclick="javascript:deleteSelectedItem_documentInfo($(this));">&times;</button>
		<a class="title" href="#"></a>
	</div>
</div>

<div id="tempListDiv" style="display:none;">
	<div class="filter-table rep" style="margin-left:5px; margin-bottom:0px;">
		<input class="pc" type="hidden" />
		<button type="button" class="close" data-dismiss="alert" onclick="javascript:deleteSelectedItem($(this));">&times;</button>
		<a class="title" href="#"></a>
	</div>
</div>

